package com.biubiux2.async;

import io.netty.util.NettyRuntime;

import java.util.concurrent.*;

/**
 * @author noexcs
 * @since 8/10/2022 4:09 PM
 */
public class FutureTaskScheduler {

    private static ExecutorService executorService;

    static {
        executorService =
                new ThreadPoolExecutor(NettyRuntime.availableProcessors(), 1000,
                        1, TimeUnit.MINUTES,
                        new ArrayBlockingQueue<>(1000), new ThreadPoolExecutor.CallerRunsPolicy());
    }

    public static void execute(Runnable runnable) {
        executorService.execute(runnable);
    }

    public static Future submit(Callable callable) {
        return executorService.submit(callable);
    }

    public static Future submit(Runnable runnable) {
        return executorService.submit(runnable);
    }
}
